package snafu.framework.objects;

import java.util.UUID;

import snafu.framework.actions.AbstractAction;
import snafu.framework.actions.AbstractReaction;
import snafu.framework.states.State;
import snafu.framework.view.Access;
import snafu.framework.view.View;

public class WorldObjectView implements WorldObject, View {

	/** The access type. */
	protected Access access;
	/** The original world object. */
	protected WorldObjectItself<? extends View> object;

	/**
	 * Instantiates a new view of the given world object.
	 * 
	 * @param access
	 *            the access type
	 * @param object
	 *            the original world object
	 */
	public WorldObjectView(Access access, WorldObjectItself<? extends View> object) {
		this.access = access;
		this.object = object;
	}
	
	/**
	 * Returns the same id as the original world object.
	 */
	@Override
	public UUID getId() {
		return this.object.id;
	}
	
	/**
	 * Returns a view of the original object's state with the same access type as this view.
	 */
	@Override
	public State getState() {
		return this.object.state.createView(access);
	}
	
	@Override
	public boolean equals(Object obj) {
		return object.equals(obj);
	}
	
	@Override
	public String output() {
		return object.output();
	}

	@Override
	public String toString() {
		return output();
	}
	
	/**
	 * Always returns null.
	 */
	@Override
	public AbstractReaction react(AbstractAction action) {
		return null;
	}
	
}
